package com.wude.guild.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wude.guild.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 通用的Dialog
 * Created by Administrator on 2017/3/15.
 */

public class MillionDialog extends Dialog {
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.context)
    TextView context;
    @BindView(R.id.ok)
    TextView ok;
    @BindView(R.id.cancel)
    TextView cancel;
    private View inflate;
    private String name;
    private String neirong;
    private View.OnClickListener dianji;
    private boolean niu = true;

    public MillionDialog(Context context, int themeResId) {
        super(context, themeResId);
        inflate = LinearLayout.inflate(context, R.layout.dialog_million, null);
    }

    public MillionDialog(Context context) {
        super(context);
    }

    protected MillionDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //  getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        setContentView(inflate);
        ButterKnife.bind(this);
        title.setText(name);
        if(niu){
            context.setText(neirong);
        }else{
            context.setVisibility(View.GONE);
        }
        ok.setOnClickListener(dianji);
    }

    public MillionDialog setTitle(String s) {
       name = s;
        return this;
    }

    public MillionDialog setContext(String s) {
        neirong = s;
        return this;
    }
    public MillionDialog setBool(boolean s) {
        niu = s;
        return this;
    }

    public MillionDialog setOkListener(View.OnClickListener onClickListener) {
       dianji = onClickListener;
        return this;
    }

    @OnClick(R.id.cancel)
    public void onClick() {
        this.dismiss();
    }
}
